package com.tencreat.service.mall.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.tencreat.domain.mall.MallGoodsCollageOrder;
import com.tencreat.mapper.mall.MallGoodsCollageOrderMapper;
import com.tencreat.service.mall.IMallGoodsCollageOrderService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 拼团用户Service业务层处理
 *
 * @author tencreat
 * @date 2022-01-25
 */
@Service
public class MallGoodsCollageOrderServiceImpl extends ServiceImpl<MallGoodsCollageOrderMapper, MallGoodsCollageOrder> implements IMallGoodsCollageOrderService {


    /**
     * 查询拼团用户
     *
     * @param id 拼团用户ID
     * @return 拼团用户
     */
    @Override
    public MallGoodsCollageOrder selectMallGoodsCollageOrderById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询拼团用户列表
     *
     * @param mallGoodsCollageOrder 拼团用户
     * @return 拼团用户
     */
    @Override
    public List<MallGoodsCollageOrder> selectMallGoodsCollageOrderList(MallGoodsCollageOrder mallGoodsCollageOrder) {
        return baseMapper.selectList(Wrappers.query(mallGoodsCollageOrder));
    }

    /**
     * 新增拼团用户
     *
     * @param mallGoodsCollageOrder 拼团用户
     * @return 结果
     */
    @Override
    public int insertMallGoodsCollageOrder(MallGoodsCollageOrder mallGoodsCollageOrder) {
        mallGoodsCollageOrder.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallGoodsCollageOrder);
    }

    /**
     * 修改拼团用户
     *
     * @param mallGoodsCollageOrder 拼团用户
     * @return 结果
     */
    @Override
    public int updateMallGoodsCollageOrder(MallGoodsCollageOrder mallGoodsCollageOrder) {
        mallGoodsCollageOrder.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(mallGoodsCollageOrder);
    }

    /**
     * 批量删除拼团用户
     *
     * @param ids 需要删除的拼团用户ID
     * @return 结果
     */
    @Override
    public int deleteMallGoodsCollageOrderByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除拼团用户信息
     *
     * @param id 拼团用户ID
     * @return 结果
     */
    @Override
    public int deleteMallGoodsCollageOrderById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }

    @Override
    public void updateStatusByid(Integer id) {
        baseMapper.updateStatusByid(id);
    }
}
